package com.gemantic.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

/**
 * Hystrix服务降级
 * 
 * @author Mr.Null
 * @date 2018年2月3日 下午7:30:11
 */
@Service
public class ConsumerServiceImpl implements ConsumerService{
	
	@Autowired
    private RestTemplate restTemplate;
	
	@Override
    @HystrixCommand(fallbackMethod = "fallback")
    public String consumer() {
        return restTemplate.getForObject("http://provider-service/doGet", String.class);
    }

    public String fallback() {
        return "fallback";
    }

}
